<br/>
{{if fields.target!="simpliertinymce"}}
<table border="0" align="center">
<tr>
	<td style="font-size: 15px; color: #c0c0c0; padding-bottom: 1px;" class="c">{{!title}}</td>
</tr>
<tr>
	<td><button id="button-">{{!original_size}}, {{width}} x {{height}}</button></td>
</tr>
<tr><td height="10"></td></tr>
{{foreach size in sizes}}
<tr>
	<td><button id="button-{{size.id}}">{{!scaled_to}} {{size.width}} x {{size.height}}</button></td>
</tr>
{{/foreach}}
</table>
{{/if}}
<script>
$("button").width('100%').button().bind("click",function () {
		submit_file(this.id.match(/button-(\d*)/)[1]);
});
function submit_file(previewmode)
{
	var filename="{{path}}{{file.id}}";
	var arr;
	//if (previewmode!=undefined && previewmode!=null) {
	if (previewmode!="") filename+="-preview"+previewmode;
	filename+=".{{file.ext}}";
	switch ('{{fields.target}}') {
		case "tinymce":
			var win = tinyMCEPopup.getWindowArg("window");
			win.document.getElementById(tinyMCEPopup.getWindowArg("input")).value = filename;
			if (typeof(win.ImageDialog) != "undefined") {
				if (win.ImageDialog.getImageData) win.ImageDialog.getImageData();
				if (win.ImageDialog.showPreviewImage) win.ImageDialog.showPreviewImage(filename);
			}
			tinyMCEPopup.close();
			break;
		case "simpletinymce":
		case "simpliertinymce":
			var win = tinyMCEPopup.getWindowArg("window");
			tinyMCEPopup.getWindowArg("input")(filename);
			tinyMCEPopup.close();
			break;
	}
}
{{if fields.target=="simpliertinymce"}}
submit_file("");
{{/if}}
</script>
